package pl.squeaky.mvc.generator;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;

public class ControllerGenerator extends ClassGenerator {

	private String name;

	public ControllerGenerator(String name) {
		super(name + "Controller");
		this.name = name;
	}
	
	public void addInitHook() {
		addMethod("init");
	}
	
	public void addPreDispatchHook() {
		addMethod("preDispatch");
	}
	
	public void addPostDispatchHook() {
		addMethod("postDispatch");
	}
	
	public void addAction(String name) {
		addMethod(name + "Action");
	}
	
	public IFile generate(IFolder controllersFolder) {
		IFile file = controllersFolder.getFile(name + ".php");
		
		generate(file);
		
		return file;
	}
}
